import * as echarts from '../../ec-canvas/echarts.min'
function initChart(canvas, width, height, dpr) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr // new
  });
  canvas.setChart(chart);

  var option = {
    color: ["#37A2DA"],
    title: {
      text: '',
      left: 'center'
    },
    grid: {
      containLabel: true,
      left:'-5%',
      top:'28%',
      bottom:'2%',
      right:'5%'
    },
    tooltip: {
      show: true,
      trigger: 'axis',
      
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: [0,6,12,18,24],
      axisTick: { //x轴刻度尺
        alignWithLabel: true,
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#D9D9D9'
        }
      },
      axisLine: {//x轴线条颜色
        lineStyle: {
          color: '#999'
        }
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#D9D9D9'
        }
      },
    },
    yAxis: {
      type: 'value',
      data: [0,6,12,18,24],
      axisTick: { //x轴刻度尺
        alignWithLabel: true,
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#D9D9D9'
        }
      },
      axisLine: {//x轴线条颜色
        lineStyle: {
          color: '#999'
        }
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed'
        }
      },
      show: false
    },
    series: [
      {
        data: [82,99,154, 232, 91, 134, 290, 83, 132],
        type: 'line',
        smooth: true,//面积图改成弧形状
        lineStyle: {
            width: 0,//外边线宽度
            color: ''//外边线颜色
        },
        showSymbol: false,//去除面积图节点圆
        areaStyle: {//区域填充渐变颜色
            color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                    offset: 0, color: '#FC0985' // 0% 处的颜色
                }, {
                    offset: 0.9, color: '#870B1C' // 93.23% 处的颜色
                }],
                global: false
            }
        },
        // areaStyle: {
        //   normal: {
        //         color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
        //             offset: 1,
        //             color: '#FC0985'
        //         },
        //         {
        //           offset: 0.5,
        //             color: '#870B1C'
        //         },
        //         {
        //             offset: 0,
        //             color: '#870B1C'
        //         }])
        //     }
        // },
      }
    ]
  };
  chart.setOption(option);
  return chart;
}
Component({
  data: {
    ec:{}
  },
  lifetimes: {
    attached: function () {
      console.log('Attached')
      this.setData({
        ec: {
          onInit: initChart
        }
      });
      console.log(this.data.ec)
      this.getdata()
    },
  },
  /**
   * 组件的方法列表
   */
   methods: {
     getdata(){
       getdata

     }
   }
})